#Include <..\include\Common_For_PageManager.au3>
#Include <GuiTreeView.au3>



Dim Const $iNumber 						= Common_GetNumberInExcelSheet($oExcel,$sTreeViewFunctionName)  
Dim Const $iCurrentSheetTotalLineNumber = $iNumber[0]   ;Get all number of rows in current excel sheet.

Dim Const $sExcelSheetName = 'TreeView'
Dim Const $iRescolumn = 14

Global $sFunctionFolderPath 			= "C:\"&$sTreeViewFunctionName&"\"
Global $SamplePatch 					= "C:\"&$sTreeViewFunctionName&"\Sample\"
Global $CorrectResutPath 				= "C:\"&$sTreeViewFunctionName&"\Correct Resut\"
Global $PerformResultPath 				= "C:\"&$sTreeViewFunctionName&"\Perform Result\"

Dim Const $sQuickLinks 					= ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'QuickLinks')
Dim Const $sAllTreeView 				= ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'AllTreeView')
Dim Const $sRenameTitle 				= ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'RenameTitle')
Dim Const $sQuickLinkRenameEditBox 		= Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'QuickLinkRenameEditBox'))
Dim Const $sConfirmFolderReplacement 	= ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'ConfirmFolderReplacement')
Dim Const $sConfirmFolderReplace 		= ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'ConfirmFolderReplace')
Dim Const $sNewFolderName				= ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'NewFolderName')
Dim Const $sDocuments 					= ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'Documents')
Dim Const $sMyPictures 					= ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'MyPictures')
Dim Const $sShareDialog 				= ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'ShareDialog')
Dim Const $sNoShareRadioButton 			= Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'NoShareRadioButton'))
Dim Const $sShareRadioButton 			= Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'ShareRadioButton'))
Dim Const $sShareNameEditBox 			= Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'ShareNameEditBox'))
Dim Const $sSetPermissionsButton 		= Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'SetPermissionsButton'))
Dim Const $sSetPermissionsDialogTitle   = ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'SetPermissionsDialogTitle')
Dim Const $sAddanAccountDialogTitle 	= ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'AddanAccountDialogTitle')

Dim Const $shareMessageTitle 			= ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'shareMessageTitle')
Dim Const $sMyComputerName 				= ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'MyComputerName')
Dim Const $sDeleteFolderTitle 			= ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'DeleteFolderTitle')

Dim Const $sFolderPropertiesDialogTitle  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'FolderPropertiesDialogTitle')
Dim Const $sAddRemoveAuthorsDialogTitle  = ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'AddRemoveAuthorsDialogTitle')
Dim Const $sAddRemoveKeywordsDialogTitle = ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'AddRemoveKeywordsDialogTitle')
Dim Const $sInboxSettingsDialogTitle 	 = ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'InboxSettingsDialogTitle')
Dim Const $sAuthorsAddRemoveButton 		 = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'AuthorsAddRemoveButton'))
Dim Const $sKeywordsAddRemoveButton		 = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'KeywordsAddRemoveButton'))
Dim Const $sSetInboxCheckBox 			 = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'SetInboxCheckBox'))
Dim Const $sSettingsButton 				 = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'SettingsButton'))

Dim Const $sEmailFolderCheckBox 		 = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'EmailFolderCheckBox'))
Dim Const $sEmailFolderBrowseButton 	 = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'EmailFolderBrowseButton'))
Dim Const $sSelectFolderDialogTitle 	 = ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'SelectFolderDialogTitle')

Dim Const $sFaxFolderCheckBox 			 = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'FaxFolderCheckBox'))
Dim Const $sFaxFolderBrowseButton		 = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'FaxFolderBrowseButton'))
Dim Const $sBrowseForFolderDialogTitle	 = ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'BrowseForFolderDialogTitle')
Dim Const $sBrowseForFolderTreeView		 = ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'BrowseForFolderTreeView')
Dim Const $sApplyClassificationCheckBox  = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'ApplyClassificationCheckBox'))
Dim Const $sTreeViewAndQuickLinkView_CtrlInfo		 = ReadIniKeyValue($sPCodeIniPath, "FTP", 'TreeViewAndQuickLinkView_CtrlInfo')

Global Const $sPerformResultPath = 'C:\AutomationTest\TreeView\Perform Result\'
Global Const $sCorrectResultPath = 'C:\AutomationTest\TreeView\Correct Resut\'
;Common_WriteLog($sFaile & $MunalExecuteTestCase & ' --- ' & '' , $TestCaseID,$sTreeViewFunctionName,$bReproduceTestCase) 
;Common_WriteLog($sFaile & ":Please check "&$sCaptureImage, $TestCaseID,$sTreeViewFunctionName,$bReproduceTestCase) 
#cs
	If $hTreeViewAndQuickLinkWindow = "" Then
		Common_WriteLog($sFaile & $MunalExecuteTestCase & ' --- ' & '' , $TestCaseID,$sTreeViewFunctionName,$bReproduceTestCase)
		Common_Close_PM($hPMHandle) 
		Common_WiteTestCaseExecuteRecode($sTempTXTPath,$TestCaseID)
		Return 0
	EndIf
	
	Common_WriteLog($sFaile & ":Please check "&$sCaptureImage & '()', $TestCaseID,$sTreeViewFunctionName,$bReproduceTestCase) 

	Common_SwitchToFolderInRootDiskC($hPMHandle,$sSectionNameTreeView)

#ce


Func DeleteShareFolder($hPMHandle)
	Common_Del_DB()
	$PMTitle1 =Common_Run_PageManager()
	Common_SleepTime(6) 
	$hTreeView=ControlGetHandle($PMTitle1,"",$sTreeViewCtrInfo)
	$hItem= _GUICtrlTreeView_GetSelection($hTreeView)
	_GUICtrlTreeView_ClickItem($hTreeView, $hItem)
	Send("{DEL}")
	Send("{ENTER}")
	Common_SleepTime() 
	Send("{ENTER}")
	Common_Close_PM($hPMHandle) 
EndFunc

Func InitializeStatusForTreeView()
	DirRemove(@MyDocumentsDir& "\My Music\", 1)
	DirRemove(@MyDocumentsDir& "\New Folder\", 1)
	DirRemove(@MyDocumentsDir& "\11111\", 1)
	DirRemove(@MyDocumentsDir& "\a s d f\", 1)
	DirRemove("D:\"&$sMyPageManagerSampleFolder, 1)
	DirRemove("C:\"&$sMyPageManagerSampleFolder, 1)
	DirRemove($sFunctionFolderPath& $sMyPageManagerSampleFolder, 1)
	FileRecycleEmpty()
	FileDelete(StringLeft(@MyDocumentsDir, StringInStr(@MyDocumentsDir, "\",0, -1)) & "Pictures")
	If WinExists("Add an Account") Then
		WinActivate("Add an Account")
		Sleep(300)
		Send("{ESC}")
		Sleep(300)
	EndIf
	If WinExists("Permissions Settings") Then
		WinActivate("Permissions Settings")
		Sleep(300)
		Send("{ESC}")
		Sleep(300)
	EndIf	
	If WinExists("Share") Then
		WinActivate("Share")
		Sleep(300)
		Send("{ESC}")
		Sleep(300)
	EndIf	
	If FileExists("C:\TreeView\11111111111111111111111111111111111111111111111111") then 
		DirRemove("C:\TreeView\11111111111111111111111111111111111111111111111111", 1)
	EndIf
	If FileExists(@DesktopDir & "\My PageManager") Then
		DirRemove(@DesktopDir & "\My PageManager", 1)
		Sleep(500)
	EndIf
	If Not FileExists(@MyDocumentsDir& "\" &$sMyPageManagerSampleFolder) Then DirCreate(@MyDocumentsDir& "\" &$sMyPageManagerSampleFolder)
EndFunc

Func ScreenCaptureTreeView1($sPerformResultPath)
	_ScreenCapture_Capture($sPerformResultPath, 27, 185, 149, 935, False)
EndFunc

Func GetQuickLinkHandle($hPMHandle)
	Return ControlGetHandle($hPMHandle,"",$sQuickLinks)
EndFunc

Func SetShareFolderInPM($bShare = True)
	Common_SleepTime() 
	Send("!f")
	Common_SleepTime()
	Send("h")
	Common_SleepTime(2)
	If $bShare Then
		ControlClick($sShareDialog,"",$sShareRadioButton)
	Else
		ControlClick($sShareDialog,"",$sNoShareRadioButton)
	EndIf
	Common_SleepTime(2)
	ControlClick($sShareDialog,"",1)
	Common_SleepTime()	
EndFunc